package com.liao.furns.dao.impl;

import com.liao.furns.dao.BasicDAO;
import com.liao.furns.dao.MemberDao;
import com.liao.furns.pojo.Member;

/**
 * @author lzp
 * @version 1.0
 * lzpnb!
 */
public class MemberDaoImpl extends BasicDAO<Member> implements MemberDao {
    @Override
    public Member queryMemberByUsername(String username) {
        String sql = "SELECT * FROM `member` WHERE `username` =?";
        Member member = querySingle(sql, Member.class, username);
            return member;
    }

    @Override
    public int saveMember(Member member) {
        String sql = "INSERT INTO `member`(`username`,`password`,`email`)\n" +
                "VALUES(?,MD5(?),?)";
        return update(sql,member.getUsername(),member.getPassword(),member.getEmail());
    }

    @Override
    public Member queryMemberByUsernameAndPassword(String username, String password) {
        String sql = "SELECT * FROM `member` WHERE `username` =? AND `password` = MD5(?)";
        return querySingle(sql, Member.class,username,password);
    }
}
